package com.aoxon.cargo.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;

import com.aoxon.cargo.R;
import com.aoxon.cargo.bean.Supplier;
import com.aoxon.cargo.cache.keyCache;
import com.aoxon.cargo.loader.NormalDataLoader;
import com.aoxon.cargo.shared.MyShared;
import com.aoxon.cargo.shared.SupIndexShared;
import com.aoxon.cargo.state.MyStateUtil;

/**
 * 欢迎界面
 * 
 * @author ZZJ
 */
public class WelcomeActivity extends BaseActivity implements
		NormalDataLoader.OnLoadDataListener {

	private Intent intent;
	private NormalDataLoader normalDataLoader = new NormalDataLoader(this);

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.pub_welcome);
//		if(MyShared ==null){
//			Log.v("welcome", "yyyeey");
//		}
		MyShared.setSharedPreferences(getApplication());
		
		Supplier supplier = SupIndexShared.getSupplier();
		if (supplier == null) {
			CargoActivity.OPEN_CHOOSE = MyStateUtil.OPEN_INDEX;
			intent = new Intent(WelcomeActivity.this, CargoActivity.class);
		} else {
			keyCache.supId = supplier.getSupId();
			keyCache.key = SupIndexShared.getKey();
			intent = new Intent(WelcomeActivity.this, SupIndexActivity2.class);
		}
		new Handler().postDelayed(new Runnable() {

			public void run() {
				startActivity(intent);
				finish();
			}

		}, 300);

	}

	@Override
	public void beforeLoad() {
		// TODO Auto-generated method stub

	}

	@Override
	public void toLoad(Message msg) throws Exception {
		// TODO Auto-generated method stub

	}

	@Override
	public void afterLoad(int state) {
		// TODO Auto-generated method stub

	}

}
